<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>生物特征识别中心</title>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <meta http-equiv="Content-Language" content="zh-CN"/>
    <link rel="stylesheet" href="__CSS__/bootstrap.min.css">
    <link rel="stylesheet" href="__CSS__/my.css">
</head>
<style>
    #table-result td{
        text-align: center;
        height: 50px;
    }
</style>
<body>
{$nav}
<div style="height: 50px"></div>
<div>
    <span class="heading heading-center">酒精代谢水平结果分析</span>
</div>
<div style="height: 50px"></div>
<div align="center">
    <button type="button" class="btn btn-lg btn-primary" data-toggle="modal"
            data-target="#modal-upload">上传结果
    </button>
</div>

<!--=================添加(modal)====================-->
<div class="modal fade" id="modal-upload" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div>

                <!-- 关闭按钮× -->
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="myModalLabel">上传文件</h4>
                </div>
                <div class="modal-body" style="margin: 0 80px">
                    <!-- 上传文件表单 -->
                    <form class="form-table" id="form-upload">
                        <div style="height: 20px"></div>
                        <!-- 上传框 -->
                        <input onchange="show_file_name('#file','#file-show-name')" type="file" name="file" id="file" style="display: none"/>
                        <div class="input-group">
                            <input type="text" class="form-control" id="file-show-name" readonly="readonly"
                                   placeholder="点击选择文件" onclick="$('#file').click();">
                            <span class="input-group-btn"><button class="btn btn-default" type="button" onclick="$('#file').click();">浏览</button></span>
                        </div>

                        <div style="height: 20px"></div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" id="btn-upload" onclick="doGetReport()">提交</button>
                </div>


            </div>
        </div>
    </div>
</div>
<div style="height: 100px"></div>
<div align="center" style="width: 400px; margin: 0 auto">
    <table id="table-result" class="table" hidden="true">

    </table>
</div>
</body>
<script src="__JS__/jquery-3.2.1.min.js"></script>
<script src="__JS__/jquery.cookie.js"></script>
<script src="__JS__/bootstrap.min.js"></script>
<script src="__JS__/my.js"></script>
<script>

    function getAllele(form) {
        var formData = new FormData($( form )[0]);
        var result;
        $.ajax({
            url: "{:url('alcohol/Index/getAllele')}" ,
            type: 'POST',
            data: formData,
            async: false,
            cache: false,
            contentType: false,
            processData: false,
            success: function (returndata) {
                result=returndata;
            },
            error: function (returndata) {
                alert("getAlleleFailed");
            }
        });
        return result;
    }

    function doGetReport() {
        $("#table-result").empty();
        var alleles=getAllele("#form-upload");
        for (a in alleles){
            var sampleid=alleles[a].sampleID;
            var rs671=alleles[a].rs671;
            var rs1229984=alleles[a].rs1229984;
            var result=myAjax("{:url('alcohol/Index/makeReport')}",{'sampleid':sampleid,'rs671':rs671,'rs1229984':rs1229984});
            if(result==='ok'){
                var tr="<tr><td>"+sampleid+"</td><td><a class='btn btn-md btn-link' href='http://ytlmike.com/static/report/"+sampleid+".docx'>下载报告</a></td></tr>";
                $("#table-result").append(tr);
            }
            $("#modal-upload").modal('hide');
            $("#table-result").show(500);
        }
    }

</script>
</html>